package se.hb.eme;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.R.id;

public class Main extends Activity {

	private static final int ACTIVITY_CREATE = 0;
	/*
	 * First view, here we have to get settings etc from
	 * user. First i send the user to a view
	 * where he/she can call the different eme-api:s.
		TODO:
	 * Here whe have to fix different views, database for saving
	 * the users credentials and so on.
	 * */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}
	
	protected void onActivityResult(int requestCode, int resultCode, Intent intent){
		//TODO:collect different results and so on
		super.onActivityResult(requestCode, resultCode, intent);
		switch(resultCode){
		}
		Bundle extras = intent.getExtras();
	}
	
	
	
	@Override
	public void onOptionsMenuClosed(Menu menu) {
		// TODO Auto-generated method stub
		super.onOptionsMenuClosed(menu);
	}

	@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.eme_menu, menu);
        return true;
    }
	
	@Override
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        
    }
	
	@Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        switch(item.getItemId()) {
        case R.id.item01:
    		Intent data = new Intent(this,ApiCallerView.class);
    		startActivityForResult(data, ACTIVITY_CREATE);        	
        	return true;
        case R.id.item02:
        	return true;
        case R.id.item03:
    		Intent settings_data = new Intent(this,ApiCallerView.class);
    		startActivityForResult(settings_data, ACTIVITY_CREATE);        	
        	return true;
        default:
        	return super.onMenuItemSelected(featureId, item);
        }
    }
}